package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.Gift;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface GiftMapper {
    @Delete({
        "delete from gift",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into gift (id, name, ",
        "coin, icon, status, ",
        "create_time, update_time)",
        "values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
        "#{coin,jdbcType=INTEGER}, #{icon,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})"
    })
    int insert(Gift record);

    int insertSelective(Gift record);

    @Select({
        "select",
        "id, name, coin, icon, status, create_time, update_time",
        "from gift",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    Gift selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Gift record);

    @Update({
        "update gift",
        "set name = #{name,jdbcType=VARCHAR},",
          "coin = #{coin,jdbcType=INTEGER},",
          "icon = #{icon,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=TINYINT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Gift record);

    @Select({
            "select",
            "id, name, coin, icon, status, create_time, update_time",
            "from gift"
    })
    @ResultMap("BaseResultMap")
    List<Gift> getGiftList();
}